package com.airnewslinkosky.ticket.net.type;

import java.util.List;

import com.airnewslinkosky.ticket.model.OfficeInfo;
import com.airnewslinkosky.ticket.model.ProfitRule;

public class RequestRrofitRule {
	/** AS编码 */
	public String asID;
	/** 用户优先级别 */
	public String asPriority;
	/** 时间戳，当前接口调用时间 */
	public String timeStamp;
	/** 登录密码 */
	public String userSign;
	/** 授权码 */
	public String officeSign;
	/** 服务类型 */
	public String serviceType;
	/** 操作类型 */
	public String operateType;
	/** asToken */
	public String asToken;
	
	/** 获利规则编号 */
	public String ruleNO = "";
	/** 下级代理商户编号 */
	public String dirOfficeID = "";
	
	public String getRequestData(List<ProfitRule> profitRuleList) {
		StringBuffer sb = new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>")
		  .append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asbc='http://asbc.airnews.com/'>")
		  .append("<soapenv::Header/>")
		  .append("<soapenv:Body>")
		  .append("<asbc:ProfitRuleManage>")
		  .append("<asbc:ASID>").append(this.asID).append("</asbc:ASID>")
		  .append("<asbc:TimeStamp>").append(this.timeStamp).append("</asbc:TimeStamp>")
		  .append("<asbc:OfficeSign>").append(this.officeSign).append("</asbc:OfficeSign>")
		  .append("<asbc:UserSign>").append(this.userSign).append("</asbc:UserSign>")
		  .append("<asbc:ASToken>").append(this.asToken).append("</asbc:ASToken>")
		  .append("<asbc:RuleNO>").append(this.ruleNO).append("</asbc:RuleNO>")
		  .append("<asbc:DirOfficeID>").append(this.dirOfficeID).append("</asbc:DirOfficeID>")
		  .append("<asbc:OperateType>").append(this.operateType).append("</asbc:OperateType>")
		  .append("<asbc:ServiceType>").append(this.serviceType).append("</asbc:ServiceType>")
		  .append("<asbc:ProfitRules>");
		  for(ProfitRule profitRule:profitRuleList){
			  sb.append("<asbc:ProfitRule>")
//			    .append("<asbc:RuleNo>").append(profitRule.getRuleNo()).append("</asbc:RuleNo>")
			    .append("<asbc:DirOfficeID>").append(profitRule.getDirOfficeID()).append("</asbc:DirOfficeID>")
			    .append("<asbc:ServiceType>").append(profitRule.getServiceType()).append("</asbc:ServiceType>")
			    .append("<asbc:ProfitMethod>").append(profitRule.getProfitMethod()).append("</asbc:ProfitMethod>")
			    .append("<asbc:LocalPersent>").append(profitRule.getLocalPersent()).append("</asbc:LocalPersent>")
			    .append("<asbc:NonlocalPersent>").append(profitRule.getNonlocalPersent()).append("</asbc:NonlocalPersent>")
			    .append("<asbc:LocalAmount>").append(profitRule.getLocalAmount()).append("</asbc:LocalAmount>")
			    .append("<asbc:NonlocalAmount>").append(profitRule.getNonlocalAmount()).append("</asbc:NonlocalAmount>")
//			    .append("<CreateTime>").append(officeInfo.getCreateTime()).append("</CreateTime>")
			    .append("</asbc:ProfitRule>");
		  }
		  sb.append("</asbc:ProfitRules>")
		    .append("</asbc:ProfitRuleManage>")
		    .append("</soapenv:Body>")
		    .append("</soapenv:Envelope>");
		return sb.toString();
	}
}
